package lesson17_3;

import java.awt.*;

public class ShowWeight extends javax.swing.JApplet {
	float lbs = (float)0;
	float ozs;
	float kgs;
	float metricTons;
	String name = "somebody";
	
	public void init() {
		String lbsValue = getParameter("weight");
		if (lbsValue != null) {
			Float lbsTemp = Float.valueOf(lbsValue);
			lbs = lbsTemp.floatValue();
		}
		String personValue = getParameter("person");
		if (personValue != null){
			name = personValue;
		}
		ozs = (float)(lbs * 16);
		kgs = (float)(lbs / 2.204623);
		metricTons = (float)(lbs/ 2204.623);
	}
	
	public void paint(Graphics screen){
		Graphics2D screen2D = (Graphics2D)screen;
		screen2D.drawString("Studying the weight of " + name, 5, 30);
		screen2D.drawString("In pounds: " + lbs, 55, 50);
		screen2D.drawString("In ounces: " + ozs, 55, 70);
		screen2D.drawString("In kilograms: " + kgs, 55, 90);
		screen2D.drawString("In metric tons: " + metricTons, 55, 110);
	}

}
